/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import com.alibaba.fastjson.annotation.JSONField;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dingnangen
 */
@Entity
@Table(name = "vehicle")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Vehicle.findAll", query = "SELECT v FROM Vehicle v"),
    @NamedQuery(name = "Vehicle.findByIdvehicle", query = "SELECT v FROM Vehicle v WHERE v.idvehicle = :idvehicle"),
    @NamedQuery(name = "Vehicle.findByPlate", query = "SELECT v FROM Vehicle v WHERE v.plate = :plate"),
    @NamedQuery(name = "Vehicle.findByCapacity", query = "SELECT v FROM Vehicle v WHERE v.capacity = :capacity"),
    @NamedQuery(name = "Vehicle.findByDispatchCost", query = "SELECT v FROM Vehicle v WHERE v.dispatchCost = :dispatchCost"),
    @NamedQuery(name = "Vehicle.findByUnitTranCost", query = "SELECT v FROM Vehicle v WHERE v.unitTranCost = :unitTranCost"),
    @NamedQuery(name = "Vehicle.findBySpeed", query = "SELECT v FROM Vehicle v WHERE v.speed = :speed"),
    @NamedQuery(name = "Vehicle.findByAvailable", query = "SELECT v FROM Vehicle v WHERE v.available = :available")})
public class Vehicle implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idvehicle")
    private Integer idvehicle;
    @Size(max = 10)
    @Column(name = "plate")
    private String plate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "capacity")
    private double capacity;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dispatchCost")
    private double dispatchCost;
    @Basic(optional = false)
    @NotNull
    @Column(name = "unitTranCost")
    private double unitTranCost;
    @Basic(optional = false)
    @NotNull
    @Column(name = "speed")
    private double speed;
    @Basic(optional = false)
    @NotNull
    @Column(name = "available")
    private int available;
    @JSONField(label = "extask")
    @JoinColumn(name = "iddepot", referencedColumnName = "iddepot")
    @ManyToOne
    private Depot iddepot;
    @JSONField(label = "extask")
    @OneToMany(mappedBy = "idvehicle")
    private List<Driver> driverList;
    @JSONField(label = "extask")
    @OneToMany(mappedBy = "idvehicle")
    private List<Attendance> attendanceList;

    public Vehicle() {
    }

    public Vehicle(Integer idvehicle) {
        this.idvehicle = idvehicle;
    }

    public Vehicle(Integer idvehicle, double capacity, double dispatchCost, double unitTranCost, double speed, int available) {
        this.idvehicle = idvehicle;
        this.capacity = capacity;
        this.dispatchCost = dispatchCost;
        this.unitTranCost = unitTranCost;
        this.speed = speed;
        this.available = available;
    }

    public Integer getIdvehicle() {
        return idvehicle;
    }

    public void setIdvehicle(Integer idvehicle) {
        this.idvehicle = idvehicle;
    }

    public String getPlate() {
        return plate;
    }

    public void setPlate(String plate) {
        this.plate = plate;
    }

    public double getCapacity() {
        return capacity;
    }

    public void setCapacity(double capacity) {
        this.capacity = capacity;
    }

    public double getDispatchCost() {
        return dispatchCost;
    }

    public void setDispatchCost(double dispatchCost) {
        this.dispatchCost = dispatchCost;
    }

    public double getUnitTranCost() {
        return unitTranCost;
    }

    public void setUnitTranCost(double unitTranCost) {
        this.unitTranCost = unitTranCost;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public int getAvailable() {
        return available;
    }

    public void setAvailable(int available) {
        this.available = available;
    }

    public Depot getIddepot() {
        return iddepot;
    }

    public void setIddepot(Depot iddepot) {
        this.iddepot = iddepot;
    }

    @XmlTransient
    public List<Driver> getDriverList() {
        return driverList;
    }

    public void setDriverList(List<Driver> driverList) {
        this.driverList = driverList;
    }

    @XmlTransient
    public List<Attendance> getAttendanceList() {
        return attendanceList;
    }

    public void setAttendanceList(List<Attendance> attendanceList) {
        this.attendanceList = attendanceList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idvehicle != null ? idvehicle.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Vehicle)) {
            return false;
        }
        Vehicle other = (Vehicle) object;
        if ((this.idvehicle == null && other.idvehicle != null) || (this.idvehicle != null && !this.idvehicle.equals(other.idvehicle))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.entity.Vehicle[ idvehicle=" + idvehicle + " ]";
    }
    
}
